package com.qydp.rpc.registry;


import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author shuSheng
 * @description 服务注册中心
 * @since 2024-07-23 14:52
 */
public class ServiceRegistry {
    static Map<String, Class<?>> serviceNameWithClass = new ConcurrentHashMap<>();

    /**
     * 注册服务
     *
     * @param serviceName          服务名称
     * @param serviceRegistryClass 服务实现类
     */
    public static void register(String serviceName, Class<?> serviceRegistryClass) {
        serviceNameWithClass.put(serviceName, serviceRegistryClass);
    }

    /**
     * 获取服务
     *
     * @param serviceName 服务名称
     * @return 服务实现类
     */
    public static Class<?> getService(String serviceName) {
        return serviceNameWithClass.get(serviceName);
    }
}
